package main

import (
	"example/web-service-gin/controller"
	_ "example/web-service-gin/docs"
	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

// @title           Swagger Example API
// @version         1.0
// @description     This is a sample server celler server.
// @termsOfService  http://swagger.io/terms/

// @contact.name   API Support
// @contact.url    http://www.swagger.io/support
// @contact.email  support@swagger.io

// @license.name  Apache 2.0
// @license.url   http://www.apache.org/licenses/LICENSE-2.0.html

// @host      localhost:8080
// @BasePath

// @securityDefinitions.basic  BasicAuth
func main() {
	//  路由
	router := gin.Default()
	// html渲染LoadHTMLGlob
	router.LoadHTMLGlob("./templates/*")
	// HTML渲染
	router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
	router.GET("/show/:title", controller.Show)
	router.POST("/add", controller.Add)
	router.DELETE("/delete/:id", controller.Delete)
	router.PUT("/update/:id", controller.Update)
	// es
	router.POST("/esAdd", controller.EsAdd)
	router.GET("/esShow", controller.EsSearchAll)
	router.GET("/getById/:id", controller.GetById)
	router.DELETE("/esDelete/:id", controller.EsDelete)
	router.PUT("/esUpdate/:id", controller.EsUpdate)

	router.Run(":8080") //暴露出外部访问端口
}
